package org.come.init;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

import com.updateNew.MyQdModeJFrame;
import org.come.test.Main;
import org.come.until.Util;
import org.come.view.View;

//自动更新
public class UpdateView extends View {
    private ImageIcon background;
    private JLabel title;
    private JLabel progressBg;
	private JLabel progress;
    private ClientCheckUpdate checkUpdate;
    
    public UpdateView() {
        this.setBounds(0, 0, 1024, 720);
        setBackground(Color.YELLOW);
        int random = Util.random.nextInt(7);// 0-6
        background = new ImageIcon("skin/9000026/new_img/bg/" + random + "_gameLoading_bg.png");
        title = new JLabel("游戏加载中请稍后...");
        title.setBounds(225, 665, 600, 18);
        title.setForeground(Color.WHITE);
        title.setHorizontalAlignment(SwingConstants.CENTER);
        Font font = new Font("宋体", Font.PLAIN, 16);
        title.setFont(font);
        add(title);
        
        progress = new JLabel(new ImageIcon("skin/9000026/new_img/bg/0_2.png"));
        progress.setBounds(122, 690, (random + 1) * 100, 15);
        add(progress);
        
        progressBg = new JLabel(new ImageIcon("skin/9000026/new_img/bg/0_1.png"));
        progressBg.setBounds(112, 690, 800, 15);
        add(progressBg);
        
    }

    @Override
    protected void paintComponent(Graphics g) {
        g.drawImage(background.getImage(), 0, 0, 1024, 720, this);
        
    }



    
    public void update() {
        (this.checkUpdate = new ClientCheckUpdate(this)).start();
        if (this.checkUpdate.isDone() && !this.checkUpdate.isFailure()) {
            this.repaint();
        }
    }

    /**
     * @return 进度条
     */
    public JLabel getProgress() {
        return progress;
    }
    
	public void setProgress(JLabel progress) {
		this.progress = progress;
	}
    
    public JLabel getTitle() {
        return title;
    }

    public void setTitle(JLabel title) {
		this.title = title;
	}


}

